package com.liuyingxing.javaSpringCloudAccount.dao;

import com.liuyingxing.entity.account.RoleResource;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.springframework.stereotype.Repository;

/**
 * Created by IntelliJ IDEA.
 * @File RoleResourceDao.java
 * @Auth liuxing
 * @Date 2021/8/24 16:46
 * @Email liuxing997@foxmail.com
 */
@Mapper
@Repository
public interface RoleResourceDao {

    //插入角色对应资源信息
    @Insert("insert into account_role_resource (role_id, resource_id) values (#{roleId}, #{resourceId})")
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    void insertRoleResource(RoleResource roleResource);

    //根据资源ID删除资源信息
    @Delete("delete from account_role_resource where resource_id = #{resourceId}")
    void deleteRoleResourceByResourceId(int resourceId);

    //根据角色ID删除资源信息
    @Delete("delete from account_role_resource where role_id = #{roleId}")
    void deleteRoleResourceByRoleId(int roleId);
}
